#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2025/1/4 14:05
# @Author : ZhengQL

"""
mock作用
1、内部服务、接口的依赖
2、外部第三方接口依赖
3、被测试模块跨多个测试系统依赖，测试环境复杂且不稳定
"""
import pytest
import requests

# 参数化mock
def test_get_mock(mocker):
    mock_response_values = [200, 404, 500]

    for value in mock_response_values:
        mocker.patch("requests.get").return_value.status_code = value

        response = requests.get("http://baidu.com")
        print(response.status_code)
        assert response.status_code == value



if __name__ == '__main__':
    pytest.main()
